package org.jeecg.modules.demo.jxcx.controller;

import org.jeecg.modules.demo.jxcx.Utils.R;
import org.jeecg.modules.demo.jxcx.po.JxcMyd;
import org.jeecg.modules.demo.jxcx.service.JxcMydService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@RestController
@RequestMapping({"jxcMyd"})
public class JxcMydController {
    @Resource
    private JxcMydService jxcMydService;
    @PostMapping("add")
    public R getinfor(@RequestBody JxcMyd jxcMyd) {
        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
        String formattedDateTime = now.format(formatter);
        String id = now.format(formatter2);
        jxcMyd.setId(id);
        jxcMyd.setOther(formattedDateTime);
        return new R().ok(jxcMydService.save(jxcMyd));
    }
}
